package com.kvest.fortests.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import java.util.Iterator;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: Kvest
 * Date: 02.06.13
 * Time: 15:42
 * To change this template use File | Settings | File Templates.
 */
public class DynamicBroadcastReceiver extends BroadcastReceiver {
    private String name;

    public DynamicBroadcastReceiver(String name) {
        super();
        this.name = name;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("KVEST_TAG", "onReceive from " + name + "[" + intent.getAction() + "]:");
        Bundle extras = intent.getExtras();
        Set<String> keys = extras.keySet();
        String key;
        for (Iterator<String> it = keys.iterator(); it.hasNext();) {
            key = it.next();
            Log.d("KVEST_TAG", key + " = " + extras.get(key).toString());
        }
    }
}
